<div class='row'>
  <div id='editor_holder' class='medium-12 columns'></div>
</div>

<div class='row large-12' id='form_operations'>
  <%= button_tag '提交', class: "btn btn-primary btn-lg", id: 'submit' %>
  <span id="error_holder"></span>
</div>

<script>
  let api_value = <%=raw @routing.to_json %>;
  let method = '<%= method %>';
  let url = '<%= target %>';

  let editor = new JSONEditor(document.getElementById('editor_holder'), {
    schema: <%=raw @routing_schema || {} %>,
    no_additional_properties: true
  });
  let submit_button = document.getElementById('submit');

  if (api_value) {
    editor.setValue(api_value);
  }

  bindChangeEvent(editor, 'error_holder', submit_button);

  submit_button.addEventListener('click', function () {
    let data = {};
    data.routing = editor.getValue();
    submitData(method, url, data)
  });
</script>
